//
//  MainCell6.m
//  zhongwulegou
//
//  Created by qianfeng on 15/9/17.
//  Copyright (c) 2015年 qianfeng. All rights reserved.
//

#import "MainCell6.h"
#import "MainScrollModel.h"
#import "UIImageView+AFNetworking.h"
#import "MainCategoryCell.h"


@implementation MainCell6

- (void)awakeFromNib {
    // Initialization code
    
    [_myCollectionView registerNib:[UINib nibWithNibName:@"MainCategoryCell" bundle:nil ] forCellWithReuseIdentifier:@"MainCategoryCell"];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

#pragma mark -UICollectionViewDataSource

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 8;
}
//cell 复用
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    MainCategoryCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"MainCategoryCell" forIndexPath:indexPath];
    if (!cell) {
        cell = [[NSBundle mainBundle]loadNibNamed:@"MainCategoryCell" owner:self options:0][0];
    }
    if (self.dataArray.count > 0) {
        MainScrollModel *model = self.dataArray[indexPath.row];
        [cell.imageView setImageWithURL:[NSURL URLWithString:model.imageURL]];
    }
    
    return cell;
}

//cell的尺寸
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    CGSize size = CGSizeMake((self.frame.size.width-20)/2.0,(self.frame.size.width-20)/5.0);
    return size;
}

@end
